<?php
class CacheConfigurationHandler extends ConfigurationHandler
{
    function CacheConfigurationHandler()
    {
        if (file_exists($this->getConfigurationCacheFile()))
        {
            $serializedConfiguration = file_get_contents($this->getConfigurationCacheFile());
            $this->configuration     = unserialize($serializedConfiguration);             
        }    
    } 
    
    function setConfiguration() 
    {
        $configurationHandler    = $this->getNext();
        $this->configuration     = $configurationHandler->getConfiguration();
        $serializedConfiguration = serialize($this->configuration);
        $fp                      = fopen($this->getConfigurationCacheFile(), "w+");
        fwrite($fp, $serializedConfiguration, strlen($serializedConfiguration));
        fclose($fp);     
        
        $this->setUpdateTime(filemtime($this->getConfigurationXMLFile()));   
    }
    
    function getConfigurationCacheFile()
    {
        return Barakus::getPath('Application.Temp.Cache') . '/__config.cache';
    } 
}
?>
